<?php

namespace App\Common\Traits\Customer;

use App\Models\ShopDetail;
use App\Models\SubAccount\SubAccount;

trait CustomerTrait
{

    //停用该客户所有账号
    public function disableAllSubAccounts($customer){
        $shopIds=$customer->getShopArr();
        if(count($shopIds)){
            $shopData=[
                'cooperation_status'=>2,
                'breakup_time'=>now(),
            ];
            ShopDetail::whereIn('id',$shopIds)->where('cooperation_status','<>',2)->update($shopData);

            $data=[
                'status'=>0,
                'breakup_time'=>date('Y-m-d H:i:s'),
            ];
            return SubAccount::whereIn('shop_id',$shopIds)->where('status','<>',0)->update($data);
        }
    }

}
